#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
	int n, m;
	cin >> n >> m;
	int a[n + 10];
	for(int i = 1; i <= n; i ++ ) {
		cin >> a[i];
	}
	for(int i = n - m + 1; i <= n; i ++ ) {
		cout << a[i] << " ";
	}
	for(int i = 1; i <= n - m; i ++ ) {
		cout << a[i] << " ";
	}
	
	return 0;
}

